@for /f "tokens=* usebackq" %%i IN (`"@for %%i in (.) do echo %%~nxi"`) do (
@set ROOT=%%i
)
@set PATH=d:\gradle-6.1.1\bin\;%PATH%;d:\android-sdk\tools\bin\;d:\PuTTY
set PACKAGE=sample.note

IF "%~1" NEQ "" (
call:%~1 %~2 %~3
) else (
echo Usage:^ %~0^ xxx
)
GOTO:EOF

:sdk
call sdkmanager --list|findstr 22.0.1
call sdkmanager --update "platforms;android-29"
GOTO:EOF

:publish
call:build
call:install
call:preview
GOTO:EOF

:error
adb logcat *:E
GOTO:EOF

:dismiss
adb shell settings put secure show_ime_with_hard_keyboard 0
goto:eof

:preview
@rem set file=.CalendarActivity
@REM set file=.IndexActivity
@REM set file=.EditTaskActivity
set file=.alarm.AlarmActivity
@REM set file=.EventListActivity
@rem set file=.InsertActivity
@REM set file=.UpdateActivity
@REM set file=com.kizitonwose.calendarviewsample.HomeActivity
adb shell am start -n %PACKAGE%/%file%
GOTO:EOF

:launch
adb shell monkey -p %PACKAGE% -c android.intent.category.LAUNCHER 1
GOTO:EOF

:shutdown
adb kill-server
adb "start-server"
adb remount
taskkill /f /t /im adb.exe
taskkill /f /t /im emulator.exe
GOTO:EOF

:boot
start "" d:\android-sdk\tools\emulator.exe -avd 18931
GOTO:EOF

:status
tasklist|findstr adb.exe
tasklist|findstr emulator.exe
GOTO:EOF

:reboot
call:install
call:launch
GOTO:EOF

:clear
rmdir /s /q d:\.android\avd
goto:eof

:create_avd

GOTO:HERE
call android create avd -n %RANDOM% -t "android-8"
set folder=d:\.android\avd\%RANDOM%
mkdir %folder%
call avdmanager create avd -p "%folder%" -n %RANDOM% -k "system-images;android-21;default;x86_64"
:HERE

call avdmanager create avd -n %RANDOM% -k "system-images;android-21;default;x86_64"
GOTO:EOF

:list_avd
@rem dir %userprofile%\.android\avd
dir d:\.android\avd
call avdmanager list avd
GOTO:EOF

:capture
color a
chcp 65001
echo=
set YYYYmmdd=%date:~3,4%%date:~8,2%%date:~11,2%
set hmmss=%time:~1,1%%time:~3,2%%time:~6,2%
set "filename=%YYYYmmdd%_%hmmss%.png"
set screen=/sdcard/screen.png
adb shell screencap -p %screen%
adb pull %screen% %filename%
GOTO:EOF

:logger
set PACKAGE=sample.note
adb pull /storage/emulated/0/Android/data/%PACKAGE%/files/%1 log\%1
type log\%1
GOTO:EOF

:install
adb uninstall sample.note
adb install "app/build/outputs/apk/release/app-release.apk"
GOTO:EOF

:uninstall
adb uninstall sample.note
GOTO:EOF

:debug
call gradlew.bat assembleDebug
adb uninstall %PACKAGE%
adb install "app/build/outputs/apk/debug/app-debug.apk"
adb shell pm list packages|findstr %PACKAGE%
call:launch
GOTO:EOF

:build
call gradlew.bat assembleRelease
GOTO:EOF

:pull
adb pull /storage/emulated/0/Android/data/%PACKAGE%/files/%1 log\%1
type log\%1
GOTO:EOF

:ls
adb shell ls /storage/emulated/0/Android/data/%PACKAGE%/files/
goto:eof

goto:here
emulator -list-avds
adb devices
adb shell wm size
adb shell wm size 720x1024
adb shell wm size reset
adb shell wm density
adb shell wm density 160
adb shell wm density reset
adb shell dumpsys "activity activities | grep mFocusedActivity"
adb shell dumpsys activity services
adb shell am broadcast

android.net.conn.CONNECTIVITY_CHANGE
android.intent.action.SCREEN_ON
android.intent.action.SCREEN_OFF
android.intent.action.BATTERY_LOW
android.intent.action.BATTERY_OKAY
android.intent.action.BOOT_COMPLETED
android.intent.action.DEVICE_STORAGE_LOW
android.intent.action.DEVICE_STORAGE_OK
android.intent.action.PACKAGE_ADDED
android.net.wifi.STATE_CHANGE
android.net.wifi.WIFI_STATE_CHANGED
android.intent.action.BATTERY_CHANGED
android.intent.action.INPUT_METHOD_CHANGED
android.intent.action.ACTION_POWER_CONNECTED
android.intent.action.ACTION_POWER_DISCONNECTED
android.intent.action.DREAMING_STARTED
android.intent.action.DREAMING_STOPPED
android.intent.action.WALLPAPER_CHANGED
android.intent.action.HEADSET_PLUG
android.intent.action.MEDIA_UNMOUNTED
android.intent.action.MEDIA_MOUNTED
android.os.action.POWER_SAVE_MODE_CHANGED

avdmanager list avd
avdmanager delete avd -n 26712
:here
